package com.googlecode.androidutils.database;

import android.database.Cursor;

/**
 * Interface for reader objects that consume a current {@link Cursor cursor row}
 * and produce an object from the values.
 * 
 * @author Alexander Metzner
 * 
 * @param <T>
 *            the type of object to return for each row
 * @see SQLiteDatabaseTemplate
 */
public interface CursorReader<T> {
	/**
	 * Called by the {@link SQLiteDatabaseTemplate template} to read a single
	 * row and transform it to an object which is returned. The template will
	 * manage the cursor (i.e. move it to the next row and close it after the
	 * last row has been consumed).
	 * 
	 * @param cursor
	 *            the cursor to read values from
	 * @return the converted object
	 */
	T readFromCursor(final Cursor cursor);
}